import { post, get } from '@/utils/request'
import request from '../utils/request'

// 获取用户好友列表
export function getFriendList(){
  return request.get('/ship/userlist')
}

// 用户名查询用户
export function searchByUsername(data){
  return request.get('/sysuser/getbyname?username=' + data)
}

// 添加好友
export function appendFriend(data) {
  return request.post('/ship/append?username=' + data)
}

// 删除好友
export function delFriend(friend_id) {
  return request.get('/ship/' + friend_id)
}

// 获取申请列表
export function listApply(){
  return request.get('/apply/listapply')
}

// 添加好友
export function sendApplyFriend(userId){
  return request.post('/apply/sendapply/' + userId)
}

// 同意申请
export function agreeFriend(id) {
  return request.get('/apply/agree/' + id)
}

// 删除申请记录
export function delApply(id) {
  return request.get('/apply/delapply/' + id)
}


// 获取好友列表服务接口
export const ServeGetContacts = data => {
  return get('/api/v1/contacts/list', data)
}

// 好友申请服务接口
export const ServeCreateContact = data => {
  return post('/api/v1/contacts/add', data)
}

// 解除好友关系服务接口
export const ServeDeleteContact = data => {
  return post('/api/v1/contacts/delete', data)
}

// 修改好友备注服务接口
export const ServeEditContactRemark = data => {
  return post('/api/v1/contacts/edit-remark', data)
}

// 查询好友申请未读数量服务接口
export const ServeFindFriendApplyNum = () => {
  return get('/api/v1/contacts/apply-unread-num')
}

// 查询好友申请服务接口
export const ServeGetContactApplyRecords = data => {
  return get('/api/v1/contacts/apply-records', data)
}

// 处理好友申请服务接口
export const ServeHandleFriendApply = data => {
  return post('/api/v1/contacts/accept-invitation', data)
}

// 删除好友申请记录服务接口
export const ServeDeleteContactApply = data => {
  return post('/api/v1/contacts/delete-apply', data)
}

// 搜索联系人
export const ServeSearchContact = data => {
  return get('/api/v1/contacts/search', data)
}
